package chapter03.s07static.example13;

// static
// 背景举例： school成员变量 存在重复存储的问题
// main函数中定义了3个Student对象，school成员变量存储了3遍
class Student {
    String name;                                        // 定义name属性
    int age;                                            // 定义age属性
    String school = "A大学";                            // 定义school属性

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void info() {
        System.out.println("姓名:" + this.name + "，年龄:" + this.age + "，学 校:" + school);
    }
}

public class Example13 {
    public static void main(String[] args) {
        Student stu1 = new Student("张三", 18);    // 创建学生对象
        Student stu2 = new Student("李四", 19);
        Student stu3 = new Student("王五", 20);
        stu1.info();
        stu2.info();
        stu3.info();
    }
}
